package com.nnnu.wsnackshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nnnu.wsnackshop.pojo.entity.Reviews;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 评价表 Mapper 接口
 * </p>
 *
 * @author zk
 * @since 2025-05-14
 */
public interface ReviewsMapper extends BaseMapper<Reviews> {

    /**
     * 获取指定商品的评价数量
     *
     * @param productId 商品ID
     * @return 评价数量
     */
    @Select("SELECT COUNT(*) FROM reviews WHERE product_id = #{productId}")
    Integer getReviewCountByProduct(@Param("productId") Integer productId);
}
